package com.train.forum.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.train.forum.pojo.vo.UserLoginVo;
import com.train.forum.service.UserService;
import com.train.forum.utils.R;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @Desc: 用户控制层 只做转发，不写逻辑业务
 * @Author: wjl
 * @DateTime: 2025/05/12 20:05:15
 */
@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
public class UserController {
    private final UserService service;


    /**
     * @param vo
     * @Desc: 用户登录
     * @Author: wjl
     * @DateTime: 2025/05/12 20:17:51
     * @Return: @return {@link String }
     */
    @PostMapping("/login")
    public R login(@RequestBody UserLoginVo vo) {
        return service.login(vo.getPhone(),vo.getPassword());
    }

    /**
     * @Desc: 测试
     * @Author: wjl
     * @DateTime: 2025/05/12 20:17:51
     * @Return: @return {@link String }
     */
    @GetMapping("/hello")
    @SaCheckLogin
    public String hello() {
        return "Hello World";
    }
}
